#ifndef GAMEBOARD_H
#define GAMEBOARD_H

#include <QWidget>
#include <QGridLayout>
#include "tile.h"

class GameBoard : public QWidget
{
    Q_OBJECT

public:
    GameBoard(QWidget* parent = nullptr);
    ~GameBoard();

private:
    QGridLayout* gameLayout;
    QVector<QVector<Tile*>> board; // 2D vector to store the game tiles
    Tile* firstClickedTile = nullptr; // Add a pointer to store the first clicked tile
    QVector<QPair<int, int>> drawPath;

public slots:
    void startNewGame(); // Slot to start a new game
    void checkGameWon();

private slots:
    void paintEvent(QPaintEvent* event);
    void clearBoard();
    void createNewBoard();
    void onTileClicked(Tile* tile); // Add a slot to handle the tile clicked signal
    bool isPathExist(Tile* tile1, Tile* tile2);

signals:
    void gameWon(); // Signal emitted when the game is won
};

#endif // GAMEBOARD_H
